<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
set_html('title','我的佣金');
if($_RQ['op']=='main'){
	$return['params']=array(
		'level'=>1,
	);
	$params=array('mid'=>$_SESSION['uid']);
	$return['commission_money']=pdo_getsum('jy_merch_game_commission',$params,'money');
	$return['commission_total']=pdo_count('jy_merch_game_commission',$params,'id');
	$return['list']=array();
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('mid'=>$_SESSION['uid']);
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'orderby'=>'id desc',
	);
	$list=pdo_getlist('jy_merch_game_commission',$parameter);
	if(!$list){
		exi('none');
	}
	foreach($list as &$item){
		$order=pdo_get('jy_merch_game_order',array('uniacid'=>$_SESSION['uniacid'],'ordersn'=>$item['ordersn']));
		$item['member']=model('core/member')->basic($order['mid']);
		$item['pidtitle']=pdo_getcolumn('jy_merch_game_item',array('id'=>$item['pid']),'title');
		$item['gamename']=$this->allgames2[$item['gamename']];
		$item['statustitle']=$this->commission_status[$item['status']];
		$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
		$item['level']=$item['level']?'二级分销':'一级分销';
	}
	exi($list);
}
?>